/*
 * @Description: 该文件描述
 * @FilePath: \vue-web-template\vite.config.ts
 * @Author: Brian Brian@gmail.com
 * @Date: 2024-10-25 09:32:41
 * @LastEditors: Brian Brian@gmail.com
 * @LastEditTime: 2024-10-25 15:11:44
 */

import { defineConfig, loadEnv, type ConfigEnv, type UserConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { resolve } from "node:path";
// https://vite.dev/config/
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
  const { VITE_PORT } = loadEnv(mode, __dirname);
  return {
    plugins: [vue(), vueJsx()],
    base: "./",
    resolve: {
      alias: {
        "@": resolve(__dirname, "./src"),
      },
    },
    css: {
      preprocessorOptions: {
        scss: {
          api: "modern-compiler", // or 'modern'
        },
      },
    },
    server: {
      host: "0.0.0.0", // 服务器主机名，如果允许外部访问，可设置为"0.0.0.0"
      port: +VITE_PORT,
      cors: true,
    },
  };
});
